﻿@model OrderView

@{
    ViewData["Title"] = "订单详情";
}

<h2>@ViewData["Title"]</h2>

<dl class="row" id="printableArea">
    <dt class="col-sm-3">订单编号</dt>
    <dd class="col-sm-9">@Model.OrderNo</dd>

    <dt class="col-sm-3">商品名称</dt>
    <dd class="col-sm-9">@Model.ProductName</dd>

    <dt class="col-sm-3">买家名称</dt>
    <dd class="col-sm-9">@Model.CustomerName</dd>

    <dt class="col-sm-3">数量</dt>
    <dd class="col-sm-9">@Model.Quantity</dd>

    <dt class="col-sm-3">总金额</dt>
    <dd class="col-sm-9">@Model.TotalAmount.ToString("C")</dd>

    <dt class="col-sm-3">配送时间</dt>
    <dd class="col-sm-9">@Model.DeliveryTime.ToString("f")</dd>
</dl>

<div class="mt-4">
    <a asp-action="Index" class="btn btn-secondary">
        <i class="bi bi-list-ul"></i> 返回订单列表
    </a>

    <button onclick="printOrder()" class="btn btn-primary ms-2">
        <i class="bi bi-printer"></i> 打印订单
    </button>
</div>

@section Scripts {
    <script>
        function printOrder() {
            var printContents = document.getElementById('printableArea').innerHTML;
            var originalContents = document.body.innerHTML;

            document.body.innerHTML = printContents;
            window.print();
            document.body.innerHTML = originalContents;
            window.location.reload();
        }
    </script>
}

<style media="print">
    .no-print {
        display: none !important;
    }

    body {
        padding: 20px;
        font-size: 14pt;
    }

    dl.row dt {
        font-weight: bold;
        width: 30%;
    }
</style>